package com.jf3q.front.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jf3q.common.domain.EduBanner;
import com.jf3q.common.domain.EduCourse;
import com.jf3q.common.domain.EduTeacher;
import com.jf3q.common.mapper.EduBannerMapper;
import com.jf3q.common.mapper.EduCourseMapper;
import com.jf3q.common.mapper.EduTeacherMapper;
import com.jf3q.common.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    EduBannerMapper eduBannerMapper;
    @Autowired
    EduCourseMapper eduCourseMapper;
    @Autowired
    EduTeacherMapper eduTeacherMapper;
     @Autowired
    RedisTemplate redisTemplate;

    @GetMapping("/banner")
    public ResultVo banner(){
        List<EduBanner> banners = eduBannerMapper.selectList(new QueryWrapper<EduBanner>());
        return ResultVo.success("获取成功",banners);
    }
    @GetMapping("/indexFront")
    public ResultVo indexFront(){
        List<EduTeacher> teacherList = eduTeacherMapper.selectList(new QueryWrapper<EduTeacher>().orderByDesc("sort").last("LIMIT 4"));
        List<EduCourse> eduList = redisTemplate.opsForList().range("Key",0,-1);
        System.out.println(1);
        System.out.println(eduList);
        Map map=new HashMap();
        map.put("eduList",eduList);
        map.put("teacherList",teacherList);
        return ResultVo.success("获取成功",map);
    }


}
